package flc.ast.utils;

import com.blankj.utilcode.util.GsonUtils;
import com.blankj.utilcode.util.SPUtils;
import com.google.gson.reflect.TypeToken;

import java.util.List;

import flc.ast.bean.CommemorateBean;
import flc.ast.bean.NoteBean;


public class AppSpUtils {
    private static final String SP_NAME = "appCollSp";
    private static final SPUtils sSpUtils = SPUtils.getInstance(SP_NAME);

    public static void saveNoteList(List<NoteBean> list) {
        String json = GsonUtils.toJson(list);
        sSpUtils.put(Key.key_note_list, json);
    }

    public static List<NoteBean> getNoteList() {
        String json = sSpUtils.getString(Key.key_note_list);
        return GsonUtils.fromJson(json, new TypeToken<List<NoteBean>>() {
        }.getType());
    }

    public static void saveCommemorateList(List<CommemorateBean> list) {
        String json = GsonUtils.toJson(list);
        sSpUtils.put(Key.key_commemorate_list, json);
    }

    public static List<CommemorateBean> getCommemorateList() {
        String json = sSpUtils.getString(Key.key_commemorate_list);
        return GsonUtils.fromJson(json, new TypeToken<List<CommemorateBean>>() {
        }.getType());
    }

    interface Key {
        String key_note_list = "key_note_list";
        String key_commemorate_list = "key_commemorate_list";

    }
}